/*
Copyright (C) 2010  Christoph Schnack, Berlin (Germany)

This file is part of Tribuit.

    Tribuit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Tribuit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tribuit.  If not, see <http://www.gnu.org/licenses/>.
*/
package GuiTools;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.*;

import Settings.Settings;
import Tribuit.Tribuit;

/**
 * A TribuitTextField extension that listens to 
 * 
 * @author Christoph Schnack
 *
 */
public class TribuitTextField extends JTextField {
	Settings SET;
	TribuitTextField field;
	public TribuitTextField(Settings set){
		super();
		SET=set;
		init();
	}
	public TribuitTextField(Settings set,int i){
		super(i);
		SET=set;
		init();
	}
	public TribuitTextField(Settings set,String s,int i){
		super(s,i);
		SET=set;
		init();
	}
	public TribuitTextField(Settings set,String s){
		super(s);
		SET=set;
		init();
	}
	
	
	public void init(){
		field=this;
		this.addFocusListener(new TFFocusListener());
	}
	
	class TFFocusListener implements FocusListener{

		public void focusGained(FocusEvent arg0) {
			SET.setCurrentTextField(field);
		}

		public void focusLost(FocusEvent arg0) {}
		
	}
}
